local Account = { balance = 0 }

function Account:new(o)
  o = o or {}
  setmetatable(o, self)
  self.__index = self
  return o
end

function Account:deposit(a)
  self.balance = self.balance + a
end

function Account:withdraw(a)
  self.balance = self.balance - a
end

function Account:info()
  print("balance = " .. self.balance)
end


-- test1
local a1 = Account:new()
a1:deposit(100)
a1:withdraw(99)
a1:info()

-- test2
local VipAccount = Account:new({credit = 0 })

function VipAccount:withdraw(a)
  self.balance = self.balance - a
  self.credit = self.credit + a
end

function VipAccount:info()
  print("balance = " .. self.balance ..', credit=' .. self.credit)
end


local a2 = VipAccount:new()
a2:deposit(100)
a2:withdraw(99)
a2:info()